Uec3.CheckIsCertifyWindow = Ext.extend(Ext.app.Module, {
	id : 'checkIsCertify',
	type : 'common/checkIsCertify',

	/**
	 * Initialize this module. This function is called at startup (page
	 * load/refresh).
	 */
	init : function(initParams) {
	},
	paramsCollection : new Ext.util.MixedCollection(true),

	getParamsByKey : function(key) {
		return this.paramsCollection.get(key);
	},
	lookUpMessage : function(id) {
		var desktop = Uec3.App.getDesktop();
		var partnerId = this.getParamsByKey("partnerId");
		var partner_win = this.getParamsByKey("partner_win");
		var partner_ds = this.getParamsByKey("partner_ds");
		desktop.launchWindowByParam("simpleCompanyMessage", {
					id : id,
					winId : id,
					partner_win:partner_win,
					partnerId:partnerId,
					partner_ds:partner_ds
				});

	},
	
	getComponents : function(params) {

		var companyMessage_grid;
		var companyMessage_ds;
		var checkIsCertifyForm;
	function renderDesc(value, cellmeta, record, rowIndex, columnIndex,
				store) {
           
		var id = record.get("id");
		
			var str = "<a style='font-size:12px' href='javascript:Ext.CUR_APP.getModule(\"checkIsCertify\").lookUpMessage("
					+ id + ");'>查看信息</a>";

			return str;

		};
			var getAndRestoreCheckIsCertify = function() {

			companyMessage_ds = new Ext.data.Store({
						proxy : new Ext.data.HttpProxy({
									url : Uec3.App.Constants.homeUrl+ '/partner/query_partner!queryCompanyMessage.do'
								}),
						baseParams : {
						},
						reader : new Ext.data.JsonReader({
									totalProperty : 'totalProperty',
									root : 'root'
								}, [ {
											name : 'id'
										}, {
											name : 'name'
										}, {
											name : 'contactorIdentityCode'
										}, {
											name : 'taxCode'
										}

								]),
						remoteSort : true
					});
		};	
		
		
		
		var componentCheckIsCertifysInits = function() {
		
		
           var companyMessage_colModel = new Ext.grid.ColumnModel([
					new Ext.grid.RowNumberer(), {
						header : "ID",
						width : 60,
						dataIndex : 'id',
						hidden : true
					}, {
						header : "公司名称",
						width : 80,
						dataIndex : 'name'
					},{
						header : "法人身份证",
						width : 80,
						dataIndex : 'contactorIdentityCode'
					},{
						header : "税号",
						width : 80,
						dataIndex : 'taxCode'
					},{
						header : "操作",
						width : 80,
						dataIndex : 'desc',
						align : 'center',
						renderer : renderDesc
					}

			]);
           
           //检查是否认证按钮
			var checkButton = new Ext.Button(

					{   
						text : '检查',
						width:80,
						handler : function() {		
						
						        var queryParam = checkIsCertifyForm.getForm().findField("checkCondition").getValue().inputValue;
							    companyMessage_ds.setBaseParam("queryParam",queryParam);
						        companyMessage_ds.setBaseParam("partnerId",params.id);
						        companyMessage_ds.load({
									 callback: function(records,options,success){
							         
							         if(success){
							        	 
							        	      if(!records.length){
							        	    	  if(params.partner_win){
							        	    	     params.partner_win.buttons[0].hide();
							        	    	     params.partner_win.buttons[1].show();
							        	    	     params.partner_win.buttons[2].hide();
							        	    	     params.partner_win.buttons[3].hide();
							        	    	     params.partner_win.buttons[4].show();
							        	    	  }  
										        	 Ext.Msg.alert('提示',"不存在该认证公司");							        	    	  
							        	      }

							         }else{
							        	 
							        	 
							        	 Ext.Msg.alert('提示',"网络连接异常...请稍候再试");
							         }			  
								
							 }		
						
						});
						        
							}

					});
           
			companyMessage_grid = new Ext.grid.GridPanel(

					{
						// title:'部门信息列表',
						region : 'center',
						iconCls : 'icon-grid',
						enableColumnMove : false,
						enableColumnMoveResize : false,
						stripeRows : true,
						height : 600,
						loadMask : {
							msg : "...加载数据中"
						},
						store : companyMessage_ds,
						columnLines : false,
						cm : companyMessage_colModel,
						sm : new Ext.grid.RowSelectionModel({
									singleSelect : true
								}),
						viewConfig : {
							forceFit : true,
							columnsText : '显示的列',
							scrollOffset : 20,
							sortAscText : '升序',
							sortDescText : '降序'
						},
						bbar : new Ext.PagingToolbar({
									pageSize : 10,
									store : companyMessage_ds,
									display : true,
									displayInfo : true,
									displayMsg : '第 {0} - {1} 条  共 {2} 条',
									emptyMsg : "没有记录",
									items : [
									]
								})

					});
			checkIsCertifyForm = new Ext.form.FormPanel({
						labelAlign : 'right',
						frame : true,
						labelWidth : 60,
						loadingText : '加载数据中...',
						buttonAlign : 'right',
						url : '',
					items:[{
									layout : 'column',
									xtype : 'fieldset',	
									anchor:'100%',
									border : false,
						items : [
									
								{   columnWidth:0.75,								
									xtype : 'radiogroup',
									style : "color:#FF8C00;",
									fieldLabel : '检查条件',
									blankText : "检查条件必须填写",
									allowBlank : false,
									name : 'checkCondition',
									items : [{
												boxLabel : "用法人/负责人身份证号检查",
												name : "checkCondition",
												inputValue : 1,
												checked : true
											}, {
												boxLabel : "用税号检查",
												name : "checkCondition",
												inputValue : 2
											}]
								},checkButton
						]
					},
					
					companyMessage_grid
				],
		buttons :[{
					text : '关闭',

					handler : function() {

			             checkIsCertifyForm.ownerCt.close();

					},
					style : "margin-left:20px"
				}]
			});
			

		}

		function checkIsCertifysControlEvent() {
		
		
		}
        getAndRestoreCheckIsCertify();
		componentCheckIsCertifysInits();

		checkIsCertifysControlEvent();

		
		this.paramsCollection.add("partnerId", params.id);
		this.paramsCollection.add("partner_win", params.partner_win);
		this.paramsCollection.add("partner_ds", params.partner_ds);
		return checkIsCertifyForm;
	},

	/**
	 * Create this modules window here.
	 */
	createWindow : function(params) {
		
		var windowId = 'checkIsCertify';
		if (params) {
			windowId += "_" + params.winId;
		}
		var desktop = Uec3.App.getDesktop();
		var win = desktop.getWindow(windowId);
		if (!win) {
			win = desktop.createWindow({
						id : windowId,
						title : '检查客户是否认证',
						width :850,
						height :500,
						iconCls : 'acc-icon',
						shim : false,
						animCollapse : false,
						modal : true,
						plain : true,
						constrainHeader : true,
						maximizable : false,
						resizable : false,
						listeners:{"beforeshow":function(){
							
						}
			},
						taskbuttonTooltip : "检查客户是否认证",
						layout : "fit",
						tools : [{
									id : 'refresh',
									handler : Ext.emptyFn,
									scope : this
								}],
						items : [this.getComponents(params)]
					});

		}
		win.show();

	}
});